package us.nchu.onlineJudger.util;

import us.nchu.onlineJudger.factory.AbstractFactory;

public class FactoryUtil {

    public static AbstractFactory getFactory(String factoryName) throws ClassNotFoundException {
        //通过类名生成实例对象并将其返回
        Class c = Class.forName(factoryName);
        Object obj = null;
        try {
            obj = c.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return (AbstractFactory)obj;
    }
}
